home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 19
/
Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso
/
Aminet
/
comm
/
dlg
/
StoryInteracti.lha
/
StoryInteractive
/
StoryI.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-04-23
|
16KB
|
534 lines
/******************************************************************
* Story Interactive V1.2 --- I got messy again. *
* Support: Noah Cunningham (cyberguy@dixie-net.com) *
$VER: Story Interactive 1.2 -by- Noah Cunningham
******************************************************************/
OPTIONS failat 10 /* fail at 10 */
CALL PRAGMA('W','NULL') /* DISABLE REQUESTORS.. IMPORTANT IN CASE DOORS:
ISN'T ASSIGNED! */
/* Pre-define a couple of vars to save time */
bs = X2C(8) || " " || X2C(8)
yes_to_more = "Y" || bs || bs || bs || bs || bs || bs || bs || bs || bs || bs || bs || bs || bs
/* Get command line arguments & open the port */
PARSE ARG port', 'sysop', 'user','level
port = port || ':'
CALL open(userport,port)
/* check if logfile exists.. if not make one. */
IF ~EXISTS('LOGS:StoryInteractive.LOG') THEN DO
CALL OPEN(log,'LOGS:StoryInteractive.LOG','W')
WRITELN(log,"*****************************************************************")
WRITELN(log,"*** Story Interactive Logfile --- V1.2 ***")
WRITELN(log,"*****************************************************************")
WRITELN(log,"")
END
CALL CLOSE(log)
/* Display Title */
IF EXISTS("doors:StoryInteractive/Title.ans") THEN DO
CALL OPEN(disp,"doors:StoryInteractive/Title.ans",'R')
DO WHILE ~EOF(disp)
a = readln(disp)
say a
END
CALL CLOSE(disp)
a = readch(userport)
END
/* Main Routine - Nice and neat */
DO forever
CALL DispMenu
WRITECH(userport,"Enter your selection: ")
selection = READCH(userport,1)
IF selection = 1 THEN DO
SAY "1 -- Read Story"
CALL ReadStory
END
IF selection = 2 THEN DO
SAY "2 -- Add to the story"
CALL AddToStory
END
IF selection = 3 THEN DO
SAY "3 -- Send Feedback"
CALL Feedback
END
IF selection = 4 THEN DO
SAY "4 -- Quit"
CALL Quit
END
IF selection = 5 THEN DO
SAY "5 -- Info"
call News
END
IF selection = 6 & level > 250 THEN DO
SAY "6 -- Sysop Menu"
CALL SysopMenu
END
END
SAY "This should NEVER be seen... If so, Noah's made a bonehead move."
EXIT(10)
DispMenu:
/* Does an alternate file exists? If so load it. */
IF EXISTS("DOORS:StoryInteractive/MainMenu.ans") THEN DO
CALL OPEN(disp,"Doors:StoryInteractive/MainMenu.ans",'R')
DO WHILE ~EOF(disp)
a = readln(disp)
say a
END
CALL CLOSE(disp)
END
/* If not.. display generic menu. */
ELSE DO
SAY " "
SAY " "
SAY " Story Interactive! "
SAY " `'`'`'`'`'`'`'`'`' "
SAY " oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo "
SAY " [o] 1.) Read The Current Story [o] "
SAY " [o] 2.) Add to The Current Story [o] "
SAY " [o] 3.) Feedback/Suggestions [o] "
SAY " [o] 4.) Quit [o] "
SAY " [o] 5.) New Features List [o] "
IF level >250 THEN SAY " [o] 6.) Sysop Menu [o] "
SAY " [o] [o] "
SAY " [o] Version 1.2 [o] "
SAY " [o] ------- `-' [o] "
SAY " [o] By: Noah Cunningham [o] "
SAY " oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo "
SAY " "
END
RETURN
/*****************************************************
** More prompt... called after 23 lines of display **
*****************************************************/
More:
/* Setup erase-the-prompt using the backspace character and a spacebar */
answer = ""
WRITECH(userport,"[More? Y/n] ")
answer = READCH(userport,1)
IF answer = "N" | answer = "n" THEN DO
SAY "Nope!"
/* Return 1 if user said No */
RETURN(1)
END
WRITECH(userport,yes_to_more)
DROP answer
/* Return 0 is user said Yes */
RETURN(0)
/************************************************
** Read the story. And call the more prompt. **
************************************************/
ReadStory:
/* Variables needed by this function... */
Count = 0 /* Count the lines */
Value = 0 /* Value returned by More prompt */
Done = 0 /* Boolean(spelling) variable -- 0 = not done, 1 = done */
/* Read the current story and call More prompt when needed */
CALL OPEN(story,'TEXT:StoryInteractive.txt','R')
DO WHILE Done = 0
Count = Count + 1
Text = READLN(story)
SAY Text
IF Count = 23 THEN Value = More()
IF Count = 23 THEN Count = 0
Rtn = EOF(Story)
IF Rtn ~= 0 THEN Done = 1
IF Value = 1 THEN DO
/* If user responded no to more prompt... close her up. */
CALL CLOSE(story)
DROP Value
DROP Count
DROP Done
DROP Rtn
RETURN
END
END
WRITECH(userport,"[Press Any Key]")
Rtn = READCH(userport,1)
DROP Rtn
DROP Value
DROP Count
DROP Done
CALL CLOSE(story)
RETURN
AddToStory: /**** Here's where I got messy again ****/
finished = 0
DO WHILE finished = 0
/* Variables needed by this function... */
buf.0 = "NULL"
ch_number = 0
rc = D2C(10)
line_number = 1
line_of_text = ''
Done = 0 /* The beauty of being able to use the same word twice as */
DOne = 0 /* a variable by only changing the capitalization. */
/* Add to the current story */
CALL OPEN(log,'LOGS:StoryInteractive.log','A')
SAY ''
SAY '---Add To Current Story-------------------------------------------------------'
SAY 'Enter as many lines as you need.'
SAY '***** Hit Ctrl-Z on A NEW LINE when finished *****'
SAY '------------------------------------------------------------------------------'
WRITECH(userport,line_number || "> ")
DO WHILE Done = 0
ch = READCH(userport,5)
IF ch = "" THEN Done = 1
a = RIGHT(ch,1)
IF a ~= D2C(13) THEN WRITECH(userport,ch)
/* Here's a nice MESS... where I tried for days to figure out how to get rid
of the backspace key! Thanks Basil! */
line_of_text = line_of_text || ch
actual_text = COMPRESS(line_of_text,X2C(08))
g = length(actual_text) /* I got so tired I decided to goto */
h = length(line_of_text) /* using letters as variables! */
i = g - (h - g) /* <- A simple calculation that cuased days of pain. */
/* Thank god I finally did it! */
IF i > 75 | a = D2C(13) THEN do
SAY ""
buf.line_number = line_of_text
top_of_buf = line_number
line_of_text = ""
line_number = line_number + 1
WRITECH(userport,line_number || "> ")
END
END
/* Okay the user has finished... Now we go back through and check if he/she
typed backspace any, and we take out the boo-boos. */
a = 1; temp_counter = 0
DO while temp_counter < top_of_buf
temp_counter = temp_counter + 1
l_t = buf.temp_counter
DO while POS(X2C(08),l_t) ~= 0
a = POS(X2C(08),l_t) - 1
l_t = DELSTR(l_t,a,2)
END
buf.temp_counter = l_t
END
SAY ""
SAY "********************************* Your Entry ********************************"
SAY ""
temp_counter = 0
DO WHILE temp_counter < top_of_buf
temp_counter = temp_counter + 1
SAY buf.temp_counter
END
CALL CLOSE(story)
answer = ''
WRITECH(userport,"[ [Y] Yes -- Add, [R] Re-do, [A] Abort ] ->")
answer = READCH(userport)
/* If user says yes, save his entry, add to the logs, nd add to the story. */
IF answer = 'Y' | answer = 'y' | answer = '' | answer = D2C(13) THEN DO
SAY 'Yes!'
CALL OPEN(story,'TEXT:StoryInteractive.txt','A')
WRITELN(log,'*** (' user ') Added the following to the story ***')
temp_counter = 0
DO WHILE temp_counter < top_of_buf
temp_counter = temp_counter + 1
line_text = buf.temp_counter
ret = WRITELN(story,line_text)
ret = WRITELN(log,line_text)
END
CALL CLOSE(story)
CALL CLOSE(log)
DROP Done
DROP line_of_text
DROP Line_Number
DROP Rtn
SAY ''
SAY 'Added to the story!'
finished = 1
RETURN
END
ELSE IF answer = 'A' | answer = 'a' | answer = 'n' | answer = 'N' THEN DO
address command 'delete RAM:StoryInteractive.txt'
SAY "Abort!"
RETURN
END
ELSE IF answer = 'R' | answer = 'r' THEN SAY 'Redo!'
ELSE SAY "Invalid response... Assuming you meant redo."
END
RETURN
/*********************************************************
** Send feedback. Only DLG could make it this simple. **
*********************************************************/
Feedback:
/* Variables needed by this function... */
line_of_text = ""
line_number = 1
Done = 0
/* I haven't went to great lengths to make this work like I have the
Add-to-story function. This creates messages merely by shoving a big
long line of text into a file and using SendMSG to send it to the sysop.
The message on the other end won't have the correct ends of lines, but
he'll get the message. */
SAY ''
SAY '---Feedback-------------------------------------------------------'
SAY 'This will be sent to your sysop as private mail on the BBS in the '
SAY 'mail system. Press Ctrl-Z when finished. '
SAY '------------------------------------------------------------------'
CALL OPEN(msg,'RAM:Feedback.tmp','W')
WRITECH(userport,line_number || "> ")
DO WHILE Done = 0
ch = READCH(userport,5)
IF ch = "" THEN Done = 1
a = RIGHT(ch,1)
IF a~= D2C(13) THEN WRITECH(userport,ch)
line_of_text = line_of_text || ch
IF length(line_of_text) > 75 | a = D2C(13) THEN do
SAY ""
WRITELN(msg,line_of_text)
line_of_text = ""
line_number = line_number + 1
WRITECH(userport,line_number || "> ")
end
END
SAY ""
SAY ""
WRITECH(userport,"Sending Message... ")
CALL CLOSE(msg)
DROP Done
DROP line_of_text
DROP Line_Number
DROP Rtn
ADDRESS COMMAND 'DLG:SendMSG -f "' || user || '" -s "Story Interactive" -b RAM:Feedback.tmp -r "' || sysop || '" >NIL:'
ADDRESS COMMAND 'Delete RAM:Feedback.tmp'
SAY "Sent!"
RETURN
Quit:
SAY ""
WRITECH(userport,"Leaving So Soon? [Y,n] ")
answer = READCH(userport,1)
IF answer = 'N' ^ answer = 'n' THEN DO
SAY "No!"
RETURN
END
SAY "Yes."
SAY ""
EXIT
SysopMenu:
Done = 0
WRITECH(userport,X2C('1B') || "[2J" || X2C('1B') || "[H")
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ clear screen */
DO while Done = 0
SAY ''
SAY 'Sysop Menu'
SAY '=========='
SAY ''
SAY '1. Start New Story'
SAY '2. View logs'
SAY '3. Return to Main Menu'
SAY ''
WRITECH(userport,"Enter your selection," user || ": ")
selection = READCH(userport,1)
IF selection = 1 THEN do
SAY '1 -- Start New Story'
CALL NewStory
end
IF selection = 2 THEN do
SAY '2 -- View Logs'
CALL ViewLogs
end
IF selection = 3 THEN do
SAY "3 -- Return to Main Menu"
SAY ""
Done = 1
end
END
selection = 0
RETURN
News:
SAY "Story Interactive v1.2"
SAY "======================"
say ""
say "Story Interactive keeps track of a story that users can contribute their"
say "ideas to. These stories can end up funny, scary, dirty, or who knows what"
say "depending on the imaginations of the users!"
say ""
say "Story Interactive is so simple to use I don't even think insturctions are"
say "needed. But for those of us who are less fortunate upstairs--here are the"
say "instructions."
say ""
say "#1 on the main menu will let you read the currently running story. I would"
say "recommend doing this before adding to the story so you know what the story"
say "is about."
say "#2 on the main menu will let you contribute your ideas to the story. When"
say "adding to the story you will not be able to backup a line, so be careful"
say "as you type. You can backspace as much as you need on the current line, "
say "but once you hit return or you reach the end of the line and are wrapped"
say "down to the next line you may not go back to the previous line. When you"
say "finish your entry press Control and Z and you'll be prompted with a save"
say "prompt... [Y,r,a] -- Yes (accept), Redo, Abort (forget it!)"
Say "[PRESS RETURN]"
a = readch(userport) /* ... A crappy little return prompt */
say "#3 on the main menu will allow you to send feedback to the sysop about the"
say "current story, or any bugs you might run into."
say "#4 on the main menu will allow you to exit Story Interactive."
say "#5 is this information screen."
say ""
say "Contacting the author"
say "====================="
say ""
say " Internet: cyberguy@dixie-net.com"
say " BBS: The Cyber Zone (601) 728-0306"
say " Fidonet: <not available>"
say ""
say " I hope you have fun and enjoy Story Interactive!!!"
say ""
say "[PRESS RETURN]"
a = readch(userport)
RETURN
/************************************
** New Story function for sysops. **
************************************/
NewStory:
done = 0
title = ""
SAY ""
WRITECH(userport,'Enter title for new story: ')
DO while done = 0
ch = READCH(userport,5)
title = title || ch
a = RIGHT(ch,1)
IF a ~= D2C(13) THEN WRITECH(userport,ch)
IF a = D2C(13) THEN done = 1
END
r_title = title
SAY ""
/* My own little procedure for centering the title... CENTER() was cutting
off the first letter sometimes. (???) */
e = "" /* <cackle> here I went back to alphabetic */
b = LENGTH(title) /* variables again. */
c = 78 - b
d = .50 * c
do while length(e) < d
e = e || " "
end
DROP b
DROP c
DROP d
title = e || title || D2C(13)
/* Nice, huh? :) */
/* Okay.. here we move the old story... make new file with new title, and
make new logfile for this story. */
SAY "Old Story being moved to LOGS:SI.txt_old..."
address command 'copy Text:StoryInteractive.txt logs:SI.txt_old'
address command 'delete TEXT:StoryInteractive.txt'
SAY "Creating New file..."
CALL OPEN(story,'TEXT:StoryInteractive.txt','W')
SAY "Writing header/title..."
WRITELN(story,"***************************************************************************")
WRITELN(story,"")
WRITELN(story,title)
WRITELN(story,"")
CALL CLOSE(story)
SAY "Making new logfile... Old one can be found as LOG:SI.log_old "
ADDRESS COMMAND "copy logs:StoryInteractive.log logs:SI.log_old"
CALL OPEN(log,"LOGS:StoryInteractive.log",'W')
WRITELN(log,"**************************Story Interactive Logfile************************")
WRITELN(log,"<SYSTEM> New story -- " r_title)
CALL CLOSE(log)
SAY "Done!"
RETURN
/********************
** View the logs. **
********************/
ViewLogs:
b = 0;c = 0
done = 0
CALL OPEN(log,"LOGS:StoryInteractive.log",'R')
DO WHILE ~eof(log)
a = readln(log)
SAY a
b = b + 1
IF b = 23 THEN c = More()
IF c = 1 THEN DO
CALL CLOSE(log)
RETURN
END
IF b = 22 & c = 0 THEN b = 0
END
CALL CLOSE(log)
WRITECH(userport,"[PRESS ANY KEY]")
a = READCH(userport)
SAY ""
RETURN